# $Id$
# Maintainer: Sébastien Luttringer
# Contributor: Kaiting Chen <kaitocracy@gmail.com>
# Contributor: Mark Smith <markzzzsmith@yahoo.com.au>

pkgname=radvd
pkgver=2.17
pkgrel=1
pkgdesc='IPv6 Router Advertisement Daemon'
url='http://www.litech.org/radvd/'
license=('custom')
depends=('glibc')
makedepends=('check')
arch=('i686' 'x86_64')
backup=('etc/radvd.conf')
validpgpkeys=('B11F2EED32FB6728F700337C411FA8C112D91A31') # Reuben Hawkins
source=("http://www.litech.org/radvd/dist/$pkgname-$pkgver.tar.xz"{,.asc}
        "$pkgname.service")
sha1sums=('e6aefd1f94c11c198271622989deefa647a489b5'
          'SKIP'
          '2fdba3b0ed28c67dc1c04bfd1439fa4dece88bbc')

prepare() {
  cd $pkgname-$pkgver
  # apply patch from the source array (should be a pacman feature)
  local filename
  for filename in "${source[@]}"; do
    if [[ "$filename" =~ \.patch$ ]]; then
      msg2 "Applying patch ${filename##*/}"
      patch -p1 -N -i "$srcdir/${filename##*/}"
    fi
  done
  :
}

build() {
  cd $pkgname-$pkgver
  ./configure \
    --prefix=/usr \
    --sbindir=/usr/bin \
    --sysconfdir=/etc \
    --with-pidfile=/run/radvd.pid \
    --with-check \
    --mandir=/usr/share/man
  make
}

check() {
  cd $pkgname-$pkgver
  make check
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
  # default config
  install -D -m 644 radvd.conf.example "$pkgdir/etc/radvd.conf"
  # license
  install -D -m 644 COPYRIGHT "$pkgdir/usr/share/licenses/$pkgname/COPYRIGHT"
  # systemd
  install -D -m 644 ../$pkgname.service \
    "$pkgdir/usr/lib/systemd/system/$pkgname.service"
}

# vim:set ts=2 sw=2 et:
